package task02;

import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		for(int j=1;j<=n;++j) {
			BigInteger sum=new BigInteger("0");
			while(scan.hasNextBigInteger()) {
				BigInteger m=scan.nextBigInteger();
				sum=sum.add(m);
				if(m.compareTo(BigInteger.ZERO)==0)break;
			}
			System.out.println(sum);
			if(j<n)System.out.println();
		}
	}

}
